package util

import (
	"fmt"
	"os"
	"save-kindle/entity"
	"save-kindle/log"
)

// WriteFile 写入文件
func WriteFile(index int, path string, v entity.Article) {
	file, err := os.OpenFile(fmt.Sprintf("%s%d.txt", path, index), os.O_CREATE|os.O_APPEND|os.O_RDWR, 0666)
	if err != nil {
		log.PrintErr(err.Error())
	}
	defer file.Close()

	file.WriteString(v.ArticleName)
	file.WriteString(v.ArticleContent)
}
